/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package luft27.comm.mavlink;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

/**
 *
 * @author amalikov
 */
public class VfrHud implements MessagePayload {
	public float airspeed;
	public float groundspeed;
	public float alt;
	public float climb;
	public short heading;
	public short throttle;

	@Override
	public byte[] get() {
		ByteBuffer bb = ByteBuffer.allocate(256).order(ByteOrder.LITTLE_ENDIAN);
		bb.putFloat(airspeed);
		bb.putFloat(groundspeed);
		bb.putFloat(alt);
		bb.putFloat(climb);
		bb.putShort(heading);
		bb.putShort(throttle);
		return Arrays.copyOf(bb.array(), bb.position());
	}

	@Override
	public void set(byte[] data) {
		ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
		airspeed = bb.getFloat();
		groundspeed = bb.getFloat();
		alt = bb.getFloat();
		climb = bb.getFloat();
		heading = bb.getShort();
		throttle = bb.getShort();

	}
}
